A brief discussion of js statements similar to of function of {}.call of

  • 2020-05-19 04:13:23
  • OfStack

The automatic login process of sina weibo is studied, in which the encryption algorithm script is involved. There is a piece of code in the following form:

(function(){...}).call(name)

The red ones... Is the internal implementation of various functions,name is the name of an object. This form of js has never seen ah (forgive me js is not familiar with ah).

.call (name) actually USES name as this in the domain of the previous function, which means that this in the function refers to name.

The actual meaning of this code can be regarded as: the transformation of the variable name by the concrete implementation of the function, or more simply, the concrete implementation of the function is the concrete implementation of the variable name. In a sense, it is equivalent to:

var name = function(){...}

That's all for this article, I hope you enjoy it.


Related articles: